package com.dk.controller;

import com.dk.em.Result;
import com.dk.pojo.QcIqc;
import com.dk.service.QcIqcService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("qc")
@Api(tags = "来料检验服务")
public class QcIqcController {

    @Autowired
    private QcIqcService qcIqcService;

    /*增加*/
    @PostMapping
    @ApiOperation("增加来料检验单")
    public Result insertQcIqc(@RequestBody QcIqc qcIqc){
        qcIqcService.insertQcIqc(qcIqc);
        return Result.OK();
    }

    /*根据id删除*/
    @DeleteMapping
    public Result deleteById(@RequestParam Long id){
        qcIqcService.deleteById(id);
        return Result.OK();
    }

    /*批量删除*/
    @DeleteMapping("deleteAll")
    public Result deleteAll(@RequestBody List<String> ids){
        qcIqcService.deletAll(ids);
        return Result.OK();
    }

    /*修改*/
    @PutMapping
    public Result updateQcIqc(@RequestBody QcIqc qcIqc){
        qcIqcService.update(qcIqc);
        return Result.OK();
    }

    /*查询*/
    @GetMapping
    public Result selectQcIqc(){
        List<QcIqc> qciqclist = qcIqcService.selectQcIqc();
        return Result.OK().setData(qciqclist);
    }
}
